package com.example;

import java.io.*;

import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.antlr.stringtemplate.*;
import org.antlr.stringtemplate.language.*;

public class HelloWorldServlet extends HttpServlet {
	private static final long serialVersionUID = 1L;
	
	public void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException {
		response.setContentType("text/plain");
		response.getWriter().write("Hello, World4!");
		/*
		StringTemplateErrorListener listener = new StringTemplateErrorListener() {
			public void error(String msg, Throwable exc) {
				System.out.println(msg); 
			}
			public void warning(String msg) {
				System.out.println(msg); 
			}
		};
		StringTemplateGroup superGroup = new ClasspathTemplateGroup("super", "com/example");
		*/
		/*
		StringTemplateGroup superGroup = loadGroup("HelloWorld");
		StringTemplateGroup subGroup = loadGroup("SubHelloWorld");
		subGroup.setSuperGroup(superGroup);
		*/
		/*
		StringTemplate hello = superGroup.getInstanceOf("hello");
		hello.setAttribute("name", "foo");
		
		response.setContentType("text/html");
		response.getWriter().write(hello.toString() + "<br/>");
		response.getWriter().write(request.getPathInfo() + "<br/>");
		response.getWriter().write(request.getServletPath() + "<br/>");
		response.getWriter().write(request.getContextPath() + "<br/>");
		*/
	}
	/*
	private static StringTemplateGroup loadGroup(String name) {
		InputStream in = HelloWorldServlet.class.getResourceAsStream(name + ".stg");
		try {
			return new StringTemplateGroup(new InputStreamReader(in), DefaultTemplateLexer.class);
		} finally {
			if (in != null) try { in.close(); } catch(Exception ignore) {}
		}		
	}
	*/
}